package com.juc.callable.callable7;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Run {

	/**
	 * 自定义拒绝策略RejectedExecutionHandler 接口使用
	 * @param args
	 */
	public static void main(String[] args) {
		ExecutorService executorService = Executors.newCachedThreadPool();
		ThreadPoolExecutor executor = (ThreadPoolExecutor) executorService;
		executor.setRejectedExecutionHandler(new MyRejectedExecutionHandler());
		executorService.submit(new MyRunnable("A"));
		executorService.submit(new MyRunnable("B"));
		executorService.submit(new MyRunnable("C"));
		executor.shutdown();
		executorService.submit(new MyRunnable("D"));
	}
}
